package com.syy.api.system.impl;
import com.syy.api.system.service.AdminUserApi;
import com.syy.api.system.service.AdminUserService;
import com.syy.common.core.domain.entity.SysUser;
import com.syy.controller.admin.base.user.AdminUserRespDTO;
import com.syy.system.sms.BeanUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@Service
public class AdminUserApiImpl implements AdminUserApi {
    @Resource
    private AdminUserService userService;

    @Override
    public List<AdminUserRespDTO> getUserList(Collection<Long> ids) {
        // 禁用数据权限。原因是，一般基于指定 id 的 API 查询，都是数据拼接为主
            List<SysUser> users = userService.getUserList(ids);
            return BeanUtils.toBean(users, AdminUserRespDTO.class);
    }

    @Override
    public AdminUserRespDTO getUser(Long id) {
        SysUser user = userService.getUser(id);
        return BeanUtils.toBean(user, AdminUserRespDTO.class);
    }

    @Override
    public List<AdminUserRespDTO> getUserListByDeptIds(Collection<Long> deptIds) {
        List<SysUser> users = userService.getUserListByDeptIds(deptIds);
        return BeanUtils.toBean(users, AdminUserRespDTO.class);
    }
    @Override
    public void validateUserList(Collection<Long> ids) {
        userService.validateUserList(ids);
    }

    @Override
    public List<AdminUserRespDTO> getUserListByPostIds(Collection<Long> postIds) {
        List<SysUser> users = userService.getUserListByPostIds(postIds);
        return BeanUtils.toBean(users, AdminUserRespDTO.class);
    }
}
